<form class="layui-form" action="{:url()}" method="post" id="editForm">
    <div class="layui-form-item">
        <label class="layui-form-label">订单号</label>
        <div class="layui-input-inline">
            <input type="text" data-disabled class="layui-input field-orders_id" name="orders_id" disabled="disabled">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">订单详情</label>
        <div class="layui-input-inline" style="width: 500px;">
            {$goods_detail|raw}
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">物流选择</label>
        <div class="layui-input-inline w200">
            <select name="delivery_id" class="field-delivery_id" type="select" lay-verify="required">
                <!-- <option value="0">无</option> -->
                {$options|raw}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">卖家信息模板选择</label>
        <div class="layui-input-inline w200">
            <select name="seller_id" class="field-seller_id" type="select" lay-verify="required">
                <!-- <option value="0">无</option> -->
                {$seller_options|raw}
            </select>
        </div>
    </div>
    <div id="pihao">
        <div class="layui-form-item">
            <label class="layui-form-label"><i style="color:red;">*</i>批号及数量</label>
            <div class="layui-inline layui-show-xs-block specname " >
                <select name="pihao[name][]" class="field-pihao[name][]" type="select" lay-verify="required">
                    {$pihao_select|raw}
                </select>
                <!-- <input type="text"  name="pihao[name][]"  placeholder="请输入批号"   autocomplete="off" class="layui-input"> -->
            </div>
            <div class="layui-inline ">
                <input type="text" name="pihao[num][]" placeholder="请输入批号数量" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-inline layui-show-xs-block" style="margin-left: 45px;">
                <a class="layui-btn layui-btn-xs add">添加</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs del">删除</a>
            </div>
            <!-- <div class="layui-input-inline">
                <input type="text" class="layui-input field-pihao" name="pihao">
            </div> -->
        </div>
    </div>
    <!-- <div class="layui-form-item">
        <label class="layui-form-label">批号数量</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input field-pihao_num" name="pihao_num">
        </div>
    </div> -->
    <div class="layui-form-item">
        <label class="layui-form-label">包裹数量</label>
        <div class="layui-input-inline">
            <input type="text" data-disabled class="layui-input field-count" name="count">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">重量(kg)</label>
        <div class="layui-input-inline">
            <input type="text" data-disabled class="layui-input field-weight" name="weight">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">长度(cm)</label>
        <div class="layui-input-inline">
            <input type="text" data-disabled class="layui-input field-space_x" name="space_x">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">宽度(cm)</label>
        <div class="layui-input-inline">
            <input type="text" data-disabled class="layui-input field-space_y" name="space_y">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">高度(cm)</label>
        <div class="layui-input-inline">
            <input type="text" data-disabled class="layui-input field-space_z" name="space_z">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><i style="color:red;">*</i>订单价格</label>
        <div class="layui-input-inline">
            <input type="text" data-disabled class="layui-input field-order_price" name="order_price" disabled="disabled">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">备注信息</label>
        <div class="layui-input-inline">
            <input type="text" data-disabled class="layui-input field-custom_remark" name="custom_remark" placeholder="备注信息，如：易碎品">
        </div>
    </div>
    <div class="pop-bottom-bar hisi-footer">
        <input type="hidden" name="id" value="{$formData['id']}">
        <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formSubmit" lay-data="{pop: true, refresh: true}">提交保存</button>
        <a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
    </div>
</form>
{include file="system@block/layui" /}
<script>
var s = "";
layui.use(['func'], function() {
    layui.func.assign({:json_encode($formData)});
});

layui.use(['form', 'layedit'], function () {
    var form=layui.form,layedit=layui.layedit;
    var index1 = layedit.build('LAY_demo1', {
            tool: ['strong', 'italic', 'underline', 'del', '|', 'left', 'center', 'right'],
            height: 200
        });
});


// 动态 增删 规格信息
var i=0;
$('#pihao').on('click', '.add', function() {
    i++;
    var $ = layui.jquery;
    var form = layui.form
    $.ajax({
        url:"{:url('getOptions')}",
        data:{id:''},
        dataType:"json", //接口json格式
        success:function(data){
            var options = data.data;
            console.log(options);
            var html = `<div class="layui-form-item">`+
            `<label class="layui-form-label"><span class="x-red">*</span>批号及数量</label>`+
            `<div class="layui-inline specname" >`+
            ` <select name="pihao[name][]" class="field-pihao[name][]" type="select" lay-verify="required">`+
                options+
                `</select>`+
            `</div>`+
            `<div class="layui-inline">`+
            `<input type="text" name="pihao[num][]" placeholder="请输入批号数量"  autoComplete="off" class="layui-input">`+
            `</div>`+

            `<div class="layui-inline layui-show-xs-block"  style="margin-left: 45px;">`+
            `<a class="layui-btn layui-btn-xs add">添加</a>`+
            `<a class="layui-btn layui-btn-danger layui-btn-xs del">删除</a>`+
            `</div>`+
            `</div>`;
            //添加到表格最后
            $('#pihao').append(html);
            form.render('select');
        },
        error:function(data){
            layer.alert(data.msg);
            // layer.alert(JSON.stringify(data), {
            //     title: data
            // });
        }
    });

    
});

// 删除规格
$('#pihao').on('click', '.del', function() {

if ($('#pihao div label').length === 1) {
    layer.msg('只有一条不允许删除。', {
        time : 2000
    });
} else {
    //删除当前按钮所在的tr
    $(this).closest('div .layui-form-item').remove();
}
});
</script>
<!--
/**
 * editor 富文本编辑器
 * @param array $obj 编辑器的容器ID
 * @param string $name [为了方便大家能在系统设置里面灵活选择编辑器，建议不要指定此参数]，目前支持的编辑器[ueditor,umeditor,ckeditor,kindeditor]
 * @param string $upload [选填]附件上传地址
 */
-->
{:editor(['UMeditor1', 'UMeditor2'])}
{:editor(['kindeditor1', 'kindeditor2'], 'kindeditor')}
{:editor(['UEditor1', 'UEditor2'], 'ueditor')}
{:editor(['ckeditor', 'ckeditor2'], 'ckeditor')}